package com.airline.connection;

import java.util.Random;

import com.airline.beans.Customer;
import com.airline.beans.Employee;
import com.airline.beans.Flight;
import com.airline.beans.Journey;

public class DatabaseDataGeneration {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		AirlineSystemService airliness = new AirlineSystemService();
		Random rand = new Random();
		
//		//Generating 5,000 employees
//		Employee employee;
//		Customer customer;
//		//16 nationalities:
//		String [] nationality = {"Indian", "American", "Mexican", "British", "French", "Italian", "Canadian", "Slovenian",
//				"German", "Peruvian", "Japanese", "Norweigen", "Swedish", "Dutch", "Chinese", "Australian"};
//		//100 cities:
//		String [] cities = {"San Jose", "San Francisco", "New York", "Chicago", "Wolf Point", "Clinton", "Mountain View", "Boise", "Reno", "Walcott", 
//				"Fremont", "Seattle", "Cincinnati", "Miami", "Salem", "Brooklyn", "Farmington","Detroit", "San Diego", "Los Angeles", 
//				"Camden", "Minneapolis", "York", "Boulder", "Denver", "Danville", "Low Moor", "Des Moines", "Madison", "Trent",
//				"Yellow", "Flushing", "Birmingham", "Atlanta", "Worth", "Helena", "Hodges", "Hoover", "Halesburg", "Haleyville",
//				"Pollard", "Powell", "Priceville", "Ragland", "Rainsville", "Reform", "Repton", "Ridgeville", "River Falls", "King",
//				"Bond", "Bonanza", "Black Forest", "Beulah", "Berkley", "Briggsdale", "Bristol", "Lazy Acres", "Lycan", "Lindon",
//				"Lone Tree", "Placerville", "Piedra", "Rand", "Redvale", "Redlands", "Rock Creek", "Roggen", "Twin Lakes", "Valdez",
//				"Vineland", "Sonoma", "Napa", "Milan", "Rome", "Madrid", "Paris", "London", "Wales", "Bath", 
//				"Athens", "Amsterdam", "Brussels", "Utleyville", "Villa Grove", "Valmont", "Rock Island", "Moline", "Davenport", "Fulton",
//				"Tyrone", "Towner", "Towaoc", "Walsh", "Almont", "Aspen", "Alpine", "Arapahoe", "Arlington", "Atwood" };
//		//50 states:
//		String [] states = {"AL", "AK", "AZ", "AR", "CA", "CO", "CT", "DE", "FL", "GA", "HI", "ID",
//				"IL", "IN", "IA", "KS", "KY", "LA", "ME", "MD", "MA", "MI", "MN", "MS", "MO",
//				"MT", "NE", "NV", "NH", "NJ", "NM", "NY", "NC", "ND", "OH", "OR", "OK", "PA",
//				"RI", "SC", "SD", "TN", "TX", "UT", "VT", "VA", "WA", "WV", "WI", "WY"};
//		//60 address
//        String [] address = {"First Street", "Second Street", "Third Street", "Middlefield", "Lake Road", "Fourth Street", "Main Street", "Mission Street", "Lombard Street", "Mountain Road", 
//        		"Central Road", "First Avenue", "Second Avenue", "Fourth Avenue", "Skyline Drive", "455th Street", "Five Peaks Road", "Yellow Road", "Park Place", "Broadway",
//        		"Purple Road", "Green Road", "Blue Street", "City Center Street", "Stevens Creek", "De Anza Blvd", "Hope Street", "Johns Street", "Doe Lane", "Parkway Blvd",
//        		"Black Street", "Blue Avenue", "Purple Avenue", "Black Avenue", "Noe Valley", "Skyline Road", "Main Avenue", "Alvin Street", "Beach Street", "Beach Road",
//        		"Small Town Road", "Large Town Road", "Jackson Street", "Patrick Henry Drive", "Fire Street", "Rome Street", "Tree Street", "Fast Lane", "Slow Lane", "Turtle Lane",
//        		"Front Street", "Madison Avenue", "Times Square Road", "Route 45", "Dale Drive", "Road Route 2", "Rural Route 4","York Street", "Dale Road", "Turnpike Lane"};
//        //120 firstNames
//        String[] firstNames = {"Jacob", "Isabella", "Ethan", "Emma", "Michael", "Olivia", "Alexandra", "Sophie","William", "Joe",
//                        "Ava", "Joshua", "Emily", "Daniel", "Madison", "Jayden", "Abigail", "Noah", "Chloe", "Anthony", 
//                        "Mia", "Kevin", "Steve", "Jason", "Troy", "Astra", "Belinda", "Brian", "Rob", "Robert", 
//                        "Hilda", "Hannah", "Cindy", "Missy", "Flo", "Tina", "Ethel", "Maddy", "Waldo", "Gina", 
//                        "Coleen", "Sadie", "Neil", "Gloria", "Bob", "Jess", "Heidi", "Jere", "Zander", "Max", 
//                        "Marcus", "Chuck", "Herman", "Betty", "Lois", "Christine", "Jay", "Delaney", "Nathaniel", "Penny",
//                        "David", "Holly", "Susie", "Susan", "Jack", "Katie", "Joy", "Hope", "Cherish", "Billy", 
//                        "Mike", "Hanna", "Nick", "Wendy", "Florence", "Sue", "Lynn", "Edward", "Deb", "Jim", 
//                        "Amber", "Adam", "Dave", "Bill", "Justine", "Bri", "Misti", "Sam", "Samuel", "Dick",
//                        "Gary", "Sep", "Danny", "Tony", "Steven", "Valerie", "Fanny", "Gertrude", "Kenny", "Sammy",
//                        "Nicci", "Tori", "Lily", "Ben", "Randy", "Randall", "Gerry", "Jerry", "Mildred", "Tina",
//                        "George", "Nemo", "Giny", "Tim", "Nini", "Vova", "Viva", "Juris", "Maxine", "Cain"};
//        //100 LastNames
//        String[] lastNames = {"Rice", "Hunt", "Shaw", "Palmer", "Knight", "Shim", "Mills", "Ferguson", "Stone", "Snyder",
//                        "Carroll", "Kirkley", "Tirado", "Rodriquez", "Pena", "Schmitz","Sanchez", "Flores", "Marmon", "Brant",
//                        "Bryant", "Garty", "Linsey", "York", "Jael", "Mikhi", "Allex", "Smith", "Jones", "Doe",
//                        "Funk", "Johnson", "Jons", "Seckette", "Norevo", "Juane", "June", "Smoroff", "John", "Lund",
//                        "Serralheiro", "Inoval", "Malakyan", "Aydinak", "Kavis", "Lovan", "Arneil", "Grant", "Bunt", "Low",
//                        "Amell", "Dunion", "Kapila", "Tuccari", "Plac", "Civin", "Baheri", "Banibah", "Gamai", "Loon",
//                        "Haray", "Walkey", "Lynbeck", "Lownoise", "Kawamori", "Desilet", "Marguilles", "Mood", "Ginn", "Funk",
//                        "Yordon", "Nevedal", "Hipp", "Bellida", "Durcic", "Wyett", "Abizi", "Guinad", "Dello", "Iraj",
//                        "Kondki", "Kilham", "Van", "Azzouna", "Sakman", "Paniolfi", "Playah", "Purnama", "Izotz", "Luu",
//                        "Yun", "Erbet", "Dietmar", "Tate", "Ricter", "Orsins", "Tune", "Menes", "Caiden", "Amy"};
//        //7 positions
//        String[] positions = {"Pilot", "Flight Attendant", "Baggage Handler", "Manager", "Reservation Clerk", "Mechanic", "Gate Clerk"};
//        //7 descriptions
//        String[] descriptions = {"Flies the plane", "Takes care of travellers", "Handles baggage", "Manages system", "Takes reservations",
//        		"Fixes the plane", "Checks travellers in at gate"};
//        
//        //5000 employees
//        for (int i = 1; i < 5000; i++) {
//        	String fn = firstNames[rand.nextInt(120)];
//        	int workInt = rand.nextInt(7);
//        	employee = new Employee(null, fn, fn, lastNames[rand.nextInt(100)], 
//        			Integer.toString(rand.nextInt(500)) + " " + address[rand.nextInt(60)], cities[rand.nextInt(100)], states[rand.nextInt(50)], 
//        			Integer.toString(rand.nextInt(89999) + 10000) + "-" + Integer.toString(rand.nextInt(8999) + 1000), 
//        			Integer.toString(rand.nextInt(12)+1) + "/" + Integer.toString(rand.nextInt(27)+1) + "/19" + Integer.toString(rand.nextInt(80) + 10),
//        			positions[workInt], descriptions[workInt],
//        			Integer.toString(rand.nextInt(12)+1) + "/" + Integer.toString(rand.nextInt(27)+1) + "/20" + Integer.toString(rand.nextInt(2) + 10));
//        	System.out.println(airliness.createEmployee(employee));
//        }
//        
//        //100000 customers
//        for (int i = 1; i < 100000; i++) {
//        	String fn = firstNames[rand.nextInt(120)];
//        	customer = new Customer(null, fn, fn, lastNames[rand.nextInt(100)], 
//        			Integer.toString(rand.nextInt(500)) + " " + address[rand.nextInt(60)], cities[rand.nextInt(100)], states[rand.nextInt(50)], 
//        			Integer.toString(rand.nextInt(89999) + 10000) + "-" + Integer.toString(rand.nextInt(8999) + 1000), 
//        			Integer.toString(rand.nextInt(12)+1) + "/" + Integer.toString(rand.nextInt(27)+1) + "/19" + Integer.toString(rand.nextInt(80) + 10),
//        			"PN" + Integer.toString(rand.nextInt(99999) + 10000), nationality[rand.nextInt(16)]);
//        	System.out.println(airliness.createCustomer(customer));
//        }
//		
		//Generating 10000 flights
		//14 source/destination
		String[] source = {"ORD", "JFK", "DET", "ATL", "SFO", "SJC", "SEA", "PDX", "LAX", "DEN", 
				"DCA", "DFW", "MSP", "BOS"}; 
		String[] destination = {"ORD", "JFK", "DET", "ATL", "SFO", "SJC", "SEA", "PDX", "LAX", "DEN", 
				"DCA", "DFW", "MSP", "BOS"};
		//8 depart times
		String[] departureTimes = {"06:00", "08:00", "10:00", "12:00", "14:00", "16:00", "18:00", "20:00"};
		//4 airlines
		String[] airlines = {"Delta", "Southwest", "United", "Alaska"};
		//7 seat counts
		int[] seatCount = {80, 150, 30, 60, 250, 200, 100};
	
//		Flight flight = null;
//		
//		for (int i = 0; i < 10000; i++) {
//			String timePick = departureTimes[rand.nextInt(8)];
//			String arriveTime = String.format("%02d", Integer.parseInt(timePick.substring(0,2)) + rand.nextInt(3)+1) + ":00";
//			int pick1 = rand.nextInt(14);
//			int pick2 = rand.nextInt(14);
//			int pick3 = pick1 == pick2 ? ((0 < pick2 && pick2 < 14)? pick2-1 : pick2+1) : pick2;
//			String airlinepick = airlines[rand.nextInt(4)];
//			String flightNumber = "";
//			if (airlinepick.equals("Delta")) {
//				flightNumber = "DL" + String.format("%05d", i);
//			} else if (airlinepick.equals("Southwest")) {
//				flightNumber = "SW" + String.format("%05d", i);
//			} else if (airlinepick.equals("United")) {
//				flightNumber = "UN" + String.format("%05d", i);
//			} else {
//				flightNumber = "AL" + String.format("%05d", i);
//			}
//			int seats = seatCount[rand.nextInt(7)];
//			flight = new Flight(airlinepick, Integer.toString(seats), 
//			         timePick, "2 pilots, 2 flight attendants", arriveTime, destination[pick3],
//			         null, flightNumber, "OnTime", Double.toString(rand.nextInt(900) + 100.99), source[pick1], Integer.toString(seats)); 
//			System.out.println(airliness.createFlight(flight));
//		}
		
		//Generate some journey data
		for (int i = 0; i < 200; i++) {
			String airline = airlines[rand.nextInt(4)];
			int pick1 = rand.nextInt(14);
			int pick2 = rand.nextInt(14);
			int pick3 = pick1 == pick2 ? ((0 < pick2 && pick2 < 14)? pick2-1 : pick2+1) : pick2;
			Flight tempFlight = new Flight(airline,"","","","",destination[pick3],"","","","",source[pick1],"");
			Journey[] results = airliness.searchFlightItineraries(tempFlight, "0", "20");
			Journey pickedJourney = results[rand.nextInt(results.length)];
			int customerID = rand.nextInt(21000) + 20000;
			pickedJourney.setCustomerID(String.format("%09d", customerID));
			pickedJourney.setPaymentOption("Credit");
			System.out.println("Ticket#=" + airliness.createJourney(pickedJourney));
		}

	}

}
